package io.github.wjehovah.yyn.utils;

import android.view.Gravity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import io.github.wjehovah.yyn.App;
import io.github.wjehovah.yyn.R;

/**
 * Created by wuyong on 15/8/3.
 */
public class ToastUtil {
    public static void showMsg(CharSequence msg, int yOffset) {

        View view = View.inflate(App.getContext(), R.layout.toast_top_msg, null);
        TextView textView = (TextView) view.findViewById(R.id.top_toast_msg);
        textView.setText(msg);
        Toast toast = new Toast(App.getContext());
        toast.setGravity(Gravity.TOP, 0, yOffset);
        toast.setDuration(Toast.LENGTH_SHORT);
        toast.setView(view);
        toast.show();
    }

    public static void showMsg(CharSequence msg) {
        showMsg(msg, DimensionUtil.dp2px(90));
    }

    public static void ToastMsg(CharSequence msg) {
        Toast.makeText(App.getContext(), msg, Toast.LENGTH_SHORT).show();
    }
}
